<?php
/*
 * @Descripttion: 
 * @version: 1.0
 * @Author: Sam
 * @Date: 2020-05-21 16:27:08
 * @LastEditors: Sam
 * @LastEditTime: 2020-11-16 17:29:31
 */ 
namespace app\admin\model;
use think\Db;
use think\Model;
use traits\ModelTrait;
use basic\BaseModel;

class User extends BaseModel {

    protected $autoWriteTimestamp = true;
    use ModelTrait;


    /**
     * 分类列表
     *
     * @param [type] 搜索条件
     * @return void
     * @Description
     * @example
     * @author Sam
     * @since 
     */
    public static function getList($where){
        $data=self::setWhere($where)->page((int)$where['page'],(int)$where['limit'])->select();
        $data=count($data) ? $data->toArray() : [];
        $count=self::setWhere($where)->count();
        return compact('data','count');
    }

                /**
     * 获取查询条件
     * @param $where
     * @param string $alert
     * @param null $model
     * @return SystemUserLevel|null
     */
    public static function setWhere($where,$alert='',$model=null)
    {
        // $model=$model===null ? new self() : $model;
        $model = self::with('article');
        if(isset($where['name']) && $where['name']) $model=$model->where("name",'like',"%{$where['name']}%");
        return $model;
    }
}